<template>
    <uni-card class="card-copy-info" note="true" v-if="wwdUser.id">
        <view class="copy-info">
            <view v-for="item in copyMyinfo">{{item}}</view>
        </view>
        <template v-slot:footer>
            <view class="footer-box">
                <button type="primary" @tap="doCopyMyinfo">复制我的信息</button>
            </view>
        </template>
    </uni-card>
</template>

<script>
    import {mapState} from 'vuex'

    export default {
        computed: mapState([
            'userInfo',
        ]),
        data() {
            return {
                // 复制我的信息
                copyMyinfo: [],
                wwdUser: {id: null}
            };
        },
        onLoad() {
            this.loadData()
        },
        methods: {
            doCopyMyinfo() {
                if (this.copyMyinfo.length > 0) {
                    this.$utils.copy(this.copyMyinfo.join('\n'))
                }
            },
            doAppendCopyInfo() {
                let self = this
                this.copyMyinfo = []
                let user = this.wwdUser
                self.copyMyinfo.push('~~靠谱单身~~')
                self.copyMyinfo.push('姓名：' + (user.nickname || ''))
                self.copyMyinfo.push('性别：' + (user.genderDictName || ''))
              if(user.homeAreaName)
                self.copyMyinfo.push('家乡：' + (user.homeAreaName || ''))
              if(user.nowAreaName)
                self.copyMyinfo.push('目前在：' + (user.nowAreaName || ''))
              if(user.birthDay)
                self.copyMyinfo.push('出生日期：' + (user.birthDay || ''))
              if(user.maritalStatusDictName)
                self.copyMyinfo.push('婚姻状况：' + (user.maritalStatusDictName || ''))
              if(user.height)
                self.copyMyinfo.push('身高：' + (user.height || '-') + 'cm')
              if(user.weight)
                self.copyMyinfo.push('体重：' + (user.weight || '-') + 'kg')
              if(user.educationDictName)
                self.copyMyinfo.push('学历：' + (user.educationDictName || ''))
                let hourseCity = ''
                if (user.hourseCity) {
                    hourseCity = '(' + user.hourseCity + ')'
                }
                self.copyMyinfo.push('房：' + (user.isHasHourse ? '有' : '没有') + (hourseCity))
                let carCity = ''
                if (user.carCity) {
                    carCity = '(' + user.carCity + ')'
                }
                self.copyMyinfo.push('车：' + (user.isHasCar ? '有' : '没有') + (carCity))

              if(user.profession)
                self.copyMyinfo.push('职业：' + (user.profession || ''))
              if(user.smokingDictName)
                self.copyMyinfo.push('抽烟：' + (user.smokingDictName || ''))
              if(user.drinkingDictName)
                self.copyMyinfo.push('喝酒：' + (user.drinkingDictName || ''))
                self.copyMyinfo.push('自我描述：' + (user.description || ''))
                self.copyMyinfo.push('择偶标准：' + (user.standard || ''))
            },
            //加载详细基本信息，复制我的信息用
            loadData() {
                uni.showLoading({
                    title: '加载中'
                })
                this.$http.get('/user-info/userId/' + this.userInfo.id).then(res => {
                    this.wwdUser = res.data
                    this.doAppendCopyInfo()
                }).finally(() => {
                    uni.hideLoading()
                })
            }
        },
        watch: {}
    }
</script>

<style>
    .card-copy-info {
        margin: unset;
    }

    .copy-info {
        padding: 0 30px 0 30px;
    }
</style>
